package hhpoll

class PollParticipant {
    User participant
    Poll poll
    PollItem vote
    Date voteDate = new Date()

    static belongsTo = Poll   
    static constraints = { 
        participant()
        poll()
        vote(nullable:true) 
        voteDate (
            nullable:true,
            validator: { return it ? (it > new Date()) : true }
        ) 
    }

    String toString() {
        "${this.id}: " + this.participant.toString()
    }
}
